package com.zdj.collection;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhangdj
 */
public class ListCutTest {

    @Test
    public void listCut() {
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i < 30; i++) {
            list.add(i);
        }
        while (!list.isEmpty()) {
            List<Integer> subList = list.stream().limit(10).collect(Collectors.toList());
            System.out.println("推送");
            if (list.size() < 10) {
                break;
            }
            list = list.subList(10, list.size());
        }
    }
}
